ποΈGitΠ―ΡΠ°ποΈ
Node / meshtastic / Meshtastic-Android / files / docs / decisions / navigation3-api-alignment-2026-03.md
docs/decisions/navigation3-api-alignment-2026-03.md 20d934459a489ffab53d9dfd88e841ea3df58e6a (20d93445) Text, 9.22 KB
<!--
β’ Copyright (c) 2026 Meshtastic LLC
-
β’ This program is free software: you can redistribute it and/or modify
β’ it under the terms of the GNU General Public License as published by
β’ the Free Software Foundation, either version 3 of the License, or
β’ (at your option) any later version.
-->
Navigation 3 & Material 3 Adaptive β API Alignment Audit
Date: 2026-03-26
Status: Active
Scope: Adoption of Navigation 3 T3838381.1.0-beta01 Scene APIs, transition metadata, ViewModel scoping, and Material 3 Adaptive integration.
Supersedes: navigation3-parity-2026-03.md Alpha04 Changelog section (versions updated).
Current Dependency Baseline
ββββββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββ
β Library β Version β Group β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββ€
β Navigation 3 UI β T3838381.1.0-beta01 β T383838org.jetbrains.androidx.navigation3:naviβ¦ β
β Navigation Event β T3838381.1.0-alpha01 β T383838org.jetbrains.androidx.navigationevent:β¦ β
β Lifecycle ViewModel Navigation3 β T3838382.11.0-alpha02 β T383838org.jetbrains.androidx.lifecycle:lifecyβ¦ β
β Material 3 Adaptive β T3838381.3.0-alpha06 β T383838org.jetbrains.compose.material3.adaptivβ¦ β
β Material 3 Adaptive Navigation Suite β T3838381.11.0-alpha05 β T383838org.jetbrains.compose.material3:materiaβ¦ β
β Compose Multiplatform β T3838381.11.0-beta01 β T383838org.jetbrains.compose β
β Compose Multiplatform Material 3 β T3838381.11.0-alpha05 β T383838org.jetbrains.compose.material3:materiaβ¦ β
ββββββββββββββββββββββββββββββββββββββββ΄βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββ
API Audit: What's Available vs. What We Use
1. NavDisplay β Scene Architecture (available since T3838381.1.0-alpha04, stable in T383838beta01)
Available APIs we're NOT using:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββ¬ββββββ
β API β Purpose β Stβ¦ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββΌββββββ€
β T383838sceneStrategies: List<SceneStrategy<T>> β Allows NavDispβ¦ β β
β¦ β
β T383838SceneStrategy<T> interface β Custom scene cβ¦ β β
β¦ β
β T383838DialogSceneStrategy β Renders T383838entry<β¦ β β
β¦ β
β T383838SceneDecoratorStrategy<T> β Wraps/decorateβ¦ β ββ¦ β
β T383838NavEntry.metadata β Attaches typedβ¦ β β
β¦ β
β T383838NavDisplay.TransitionKey / T383838PopTransitionKey / T383838PredictivePopTransitionKey β Per-entry custβ¦ β ββ¦ β
β T383838transitionSpec / T383838popTransitionSpec / T383838predictivePopTransitionSpec params β Default transiβ¦ β β
β¦ β
β T383838sharedTransitionScope: SharedTransitionScope? β Shared elementβ¦ β ββ¦ β
β T383838entryDecorators: List<NavEntryDecorator<T>> β Wraps entry coβ¦ β β
β¦ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ΄ββββββββββββββββββ΄ββββββ
APIs we ARE using correctly:
ββββββββββββββββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββ
β API β Usage β
ββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β T383838NavDisplay(backStack, entryProvider, modifiβ¦ β Both T383838app/Main.kt and T383838desktop/DesktopMainScreen.kt β
β T383838rememberNavBackStack(SavedStateConfiguratioβ¦ β Backstack persistence β
β T383838entryProvider<NavKey> { entry<T> { ... } } β All feature graph registrations β
β T383838NavigationBackHandler from T383838navigationevent-β¦ β Used with T383838ListDetailSceneStrategy β
ββββββββββββββββββββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββ
2. ViewModel Scoping (T383838lifecycle-viewmodel-navigation3 T3838382.11.0-alpha02)
Key finding: The T383838ViewModelStoreNavEntryDecorator is available and provides automatic per-entry ViewModel scoping tied to backstack lifetime. The project passes it as an T383838entryDecorator to T383838NavDisplay via T383838MeshtasticNavDisplay in T383838core:ui/commonMain.
ViewModels obtained via T383838koinViewModel() inside T383838entry<T> blocks are scoped to the entry's backstack lifetime and automatically cleared when the entry is popped.
3. Material 3 Adaptive β Nav3 Scene Integration
Key finding: The JetBrains T383838adaptive-navigation3 artifact at T3838381.3.0-alpha06 includes T383838ListDetailSceneStrategy and T383838SupportingPaneSceneStrategy. The project uses both via T383838rememberListDetailSceneStrategy and T383838rememberSupportingPaneSceneStrategy in T383838MeshtasticNavDisplay, with draggable pane dividers via T383838VerticalDragHandle + T383838paneExpansionDraggable.
This means the project successfully uses the M3 Adaptive Scene bridge through T383838NavDisplay(sceneStrategies = ...). Feature entries annotate themselves with T383838ListDetailSceneStrategy.listPane(), T383838.detailPane(), or T383838.extraPane() metadata.
When to revisit: Monitor the JetBrains adaptive fork for T383838MaterialListDetailSceneStrategy inclusion. It will likely arrive when the JetBrains fork catches up to the AndroidX T3838381.3.0-alpha09+ feature set.
4. NavigationSuiteScaffold (T3838381.11.0-alpha05)
Status: β
Adopted (2026-03-26). T383838MeshtasticNavigationSuite now uses T383838NavigationSuiteScaffold with T383838calculateFromAdaptiveInfo() and custom T383838NavigationSuiteType coercion. No further alignment needed.
Prioritized Opportunities
P0: Add T383838ViewModelStoreNavEntryDecorator to NavDisplay (high-value, low-risk)
Status: β
Adopted (2026-03-26). Each backstack entry now gets its own T383838ViewModelStoreOwner via T383838rememberViewModelStoreNavEntryDecorator(). ViewModels obtained via T383838koinViewModel() are automatically cleared when their entry is popped. Encapsulated in T383838MeshtasticNavDisplay in T383838core:ui/commonMain.
Impact: Fixes subtle ViewModel leaks where popped entries retain their ViewModel in the Activity/Window store. Eliminates the need for manual T383838key = "metrics-$destNum" ViewModel keying patterns over time.
P1: Add default NavDisplay transitions (medium-value, low-risk)
Status: β
Adopted (2026-03-26). A shared 350 ms crossfade (T383838fadeIn + T383838fadeOut) is applied for both forward and pop navigation via T383838MeshtasticNavDisplay. This replaces the library's platform defaults (Android: 700 ms fade; Desktop: no animation) with a faster, consistent transition.
Impact: Immediate UX improvement on both Android and Desktop. Desktop now has visible navigation transitions.
P2: Adopt T383838DialogSceneStrategy for navigation-driven dialogs (medium-value, medium-risk)
Status: β
Adopted (2026-03-26). T383838MeshtasticNavDisplay includes T383838DialogSceneStrategy in T383838sceneStrategies before T383838SinglePaneSceneStrategy. Feature modules can now use T383838entry<T>(metadata = DialogSceneStrategy.dialog()) { ... } to render entries as overlay Dialogs with proper backstack lifecycle and predictive-back support.
Impact: Cleaner dialog lifecycle management available for future dialog routes. Existing dialogs via T383838AlertHost are unaffected.
Consolidation: T383838MeshtasticNavDisplay shared wrapper
Status: β
Adopted (2026-03-26). A new T383838MeshtasticNavDisplay composable in T383838core:ui/commonMain encapsulates the standard T383838NavDisplay configuration:
β’ Entry decorators: T383838rememberSaveableStateHolderNavEntryDecorator + T383838rememberViewModelStoreNavEntryDecorator
β’ Scene strategies: T383838DialogSceneStrategy + T383838SinglePaneSceneStrategy
β’ Transition specs: 350 ms crossfade (forward + pop)
Both T383838app/Main.kt and T383838desktop/DesktopMainScreen.kt now call T383838MeshtasticNavDisplay instead of configuring T383838NavDisplay directly. The T383838lifecycle-viewmodel-navigation3 dependency was moved from host modules to T383838core:ui.
P3: Per-entry transition metadata (low-value until Scene adoption)
Individual entries can declare custom transitions via T383838entry<T>(metadata = NavDisplay.transitionSpec { ... }). This is most useful when different route types should animate differently (e.g., detail screens slide in, settings screens fade).
Impact: Polish improvement. Low priority until default transitions (P1) are established. Now unblocked by P1 adoption.
Deferred: Custom Scene strategies
The T383838ListDetailSceneStrategy and T383838SupportingPaneSceneStrategy are adopted and working. Consider writing additional custom T383838SceneStrategy implementations for specialized layouts (e.g., three-pane "Power User" scenes) as the Navigation 3 Scene API matures.
Decision
~~Adopt P0 (ViewModel scoping) and P1 (default transitions) now. Defer P2/P3 and Scene-based multi-pane until the JetBrains adaptive fork adds T383838MaterialListDetailSceneStrategy.~~
Updated 2026-03-26: P0, P1, and P2 adopted and consolidated into T383838MeshtasticNavDisplay in T383838core:ui/commonMain. P3 (per-entry transitions) is available for incremental adoption by feature modules. Scene-based multi-pane remains deferred.
References
β’ Navigation 3 source: T383838navigation3-ui T3838381.1.0-beta01 (inspected from Gradle cache)
β’ NavDisplay.kt (upstream)
β’ SceneStrategy.kt (upstream)
β’ Material 3 Adaptive JetBrains fork: T383838org.jetbrains.compose.material3.adaptive T3838381.3.0-alpha06
Served by rngit 1.5.0 - Generated in 0.09s